package com.siwei.mes.controller.tc;

import com.siwei.mes.common.query.PageQuery;
import com.siwei.mes.common.result.ApiResult;
import com.siwei.mes.common.result.Json;
import com.siwei.mes.common.validator.PageGroup;
import com.siwei.mes.common.validator.UpdateGroup;
import com.siwei.mes.entity.sync.tc.SupplyTask;
import com.siwei.mes.service.sync.tc.SupplyTaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * TC-供货任务控制层
 *
 * @author yangke
 * @since 2024-05-27 15:45:00
 */
@Api(value = "TC-供货任务")
@RestController
@RequestMapping("tcSupplyTask")
public class SupplyTaskController {
    @Resource
    private SupplyTaskService supplyTaskService;

    @ApiOperation(value = "修改供货任务")
    @PostMapping("/update")
    public Json update(@RequestBody @Validated(UpdateGroup.class) SupplyTask entity) {
        supplyTaskService.update(entity);
        return Json.succ().data(new ApiResult());
    }

    @ApiOperation(value = "分页获取TC供货任务")
    @PostMapping("/page")
    public Json appPage(@RequestBody @Validated(PageGroup.class) PageQuery<SupplyTask, SupplyTask> query) {
        return Json.succ().data(supplyTaskService.getPage(query));
    }

    @ApiOperation(value = "根据主键id获取TC供货任务")
    @GetMapping("loadById")
    public Json loadById(@RequestParam("id") Long id) {
        return Json.succ().data(supplyTaskService.loadById(id));
    }

    @ApiOperation(value = "获取所有TC供货任务")
    @PostMapping("getAll")
    public Json getAll(@RequestBody SupplyTask entity) {
        return Json.succ().data(ApiResult.addList(supplyTaskService.getAll(entity)));
    }
}
